<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>添加页面</title>
</head>
<body>
<form class="layui-form" lay-filter="layui-form">
  <div class="mainBox">
    <div class="main-container">
      <div class="main-container">
        {{.__FIELD__}}
      </div>
    </div>
  </div>
  <div class="bottom">
    <div class="button-container">
      <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
        <i class="layui-icon layui-icon-ok"></i>
        提交
      </button>
      <button type="reset" class="laytp-btn laytp-btn-sm">
        <i class="layui-icon layui-icon-refresh"></i>
        重置
      </button>
    </div>
  </div>
</form>
<script>
  if(localStorage.getItem("staticDomain")){
    document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/laytp/css/laytp.css?v=" + localStorage.getItem("version") + "'>");
    document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
    document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
  }else{
    document.write("<link rel='stylesheet' href='/static/component/laytp/css/laytp.css?v=" + localStorage.getItem("version") + "'>");
    document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
    document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
  }
</script>
<script>
  layui.use(['laytp'],function(){
    layui.form.on('submit(add)', function(data){
      var btnAnim = layui.button.load({elem:$(this)});
      try{
        data = facade.setEditorField(data);
      }catch (e) {
        facade.error(e);
        return false;
      }
      facade.ajax({
        route:'{{.__API_PREFIX__}}{{.__ACT__}}',
        data : data.field
      }).done(function(res){
        if(res.code === 0){
          parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
          parent.layui.table.reloadData("laytp-table");
        }
        btnAnim.stop();
      }).fail(function(){
        btnAnim.stop();
      });
      return false;
    });
  })
</script>
</body>
</html>